<template>
  <div class="rightBodyContent">
    <div class="rightBodyContent-in">
      <div class="mb-10">
        <div class="toplineBox">
          <div class="toplineBox-left">
            <el-button size="small" @click="refreshFn()">刷新</el-button>
          </div>
          <p class="numberline toplineBox-right">总{{ page.total }}条</p>
        </div>
      </div>
      <!--本体列表，数据 -->
      <div class="table-body">
        <div class="table-body-box">
          <el-table
            ref="multipleTable"
            :data="arryList"
            :stripe="tableStyle.tableStripe"
            :border="tableStyle.tableBorder"
            tooltip-effect="dark"
            style="width: 100%"
            v-loading="loading"
            element-loading-text="拼命加载中"
            element-loading-spinner="el-icon-loading"
            element-loading-background="rgba(0, 0, 0, 0.6)"
            header-cell-class-name="table-text-c"
            cell-class-name="table-text-c"
          >
            <el-table-column
              prop="realname"
              label="用户">
            </el-table-column>
            <el-table-column
              prop="method"
              label="请求方法">
            </el-table-column>
            <el-table-column
              prop="module"
              label="模块">
            </el-table-column>
            <el-table-column
              prop="name"
              label="节点图">
              <template slot-scope="scope">
                {{ scope.row.controller }}/{{ scope.row.action }}
              </template>
            </el-table-column>
            <el-table-column
              prop="name"
              label="时间">
              <template slot-scope="scope">
                {{ yeartime(scope.row.create_at) }}
              </template>
            </el-table-column>
          </el-table>
        </div>
      </div>
      <!--工具条 分页-->
      <el-col :span="24" class="toolbar">
        <el-pagination
          background
          layout="total, prev, pager, next"
          :total="page.total"
          :page-size="page.pagesize"
          @current-change="handleSizeChange">
        </el-pagination>
      </el-col>
    </div>
  </div>
</template>

<script>
import {pagination, tableoption, yeartime} from '@/utils/util.js'
import {system_log} from '@/api/admin/systemSetting'

export default {
  components: {},
  data() {
    return {
      arryList: [],
      // 设置table样式
      tableStyle: tableoption,
      // 设置table页面分页所需
      page: {
        pageindex: pagination.pageIndex,
        pagesize: pagination.pageSize,
        total: pagination.total
      },
      yeartime: yeartime,
      loading: true
    }
  },
  created() {
    this.InitFn()
  },
  methods: {
    // 初始化
    InitFn() {
      system_log({
        p: this.page.pageindex
      }).then(response => {
        this.arryList = response.list.data
        this.page.total = response.list.total
        this.loading = false
      })
    },
    handleSelectionChange(val) {
      this.handleSelection = val
    },
    // 分页
    handleSizeChange(val) {
      this.loading = true
      this.page.pageindex = val
      this.InitFn()
    },
    // 刷新页面
    refreshFn() {
      this.loading = true
      this.page.pageindex = 1
      this.InitFn()
    }
  },
  mounted() {
  }
}
</script>
